package com.ruoyi.tiktok.mapper;

import com.ruoyi.tiktok.domain.Task;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface taskMapper {

    @Update("UPDATE tasks SET taskStatus=#{taskStatus}, taskCreateUserName=#{taskCreateUserName}," +
            "videoTopic=#{videoTopic}, videoTitle=#{videoTitle}" +" WHERE taskId=#{taskId}")
    int updateTask(Task task);

    @Delete("DELETE FROM tasks WHERE taskId=#{taskId}")
    void deleteTask(String taskId);

    @Select("SELECT * FROM tasks WHERE taskId=#{taskId}")
    Task getTaskById(String taskId);

    @Insert("INSERT INTO tasks(taskId, videoTotalCount, taskStatus, taskCreateTime, taskCreateUserName," +
            " taskCreateUserId, taskAddress, videoTitle, title, videoTopic, mountStyle, destination) " +
            "VALUES(#{taskId}, #{videoTotalCount}, #{taskStatus}, #{taskCreateTime}, #{taskCreateUserName}, " +
            "#{taskCreateUserId}, #{taskAddress}, #{videoTitle}, #{title}, #{videoTopic}, #{mountStyle}, #{destination})")
    void insertTask(Task task);

    @Select(" select t.taskId, t.title, t.taskStatus, t.taskCreateUserName, t.taskCreateTime from tasks t")
    List<?> testSelect();

    /**
     * 查询distribute
     *
     * @param taskId distribute主键
     * @return distribute
     */
    public Task selectTasksByTaskId(String taskId);

    /**
     * 查询distribute列表
     *
     * @param tasks distribute
     * @return distribute集合
     */
    public List<Task> selectTasksList(Task tasks);

    /**
     * 新增distribute
     *
     * @param tasks distribute
     * @return 结果
     */
    public int inserttasks(Task tasks);

    /**
     * 修改distribute
     *
     * @param tasks distribute
     * @return 结果
     */
    public int updateTasks(Task tasks);

    /**
     * 删除distribute
     *
     * @param taskId distribute主键
     * @return 结果
     */
    public int deletetasksByTaskId(String taskId);

    /**
     * 批量删除distribute
     *
     * @param taskIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deletetasksByTaskIds(String[] taskIds);
}

